# Maintainer: Jerome Leclanche <jerome@leclan.ch>

pkgname=git-filter-repo
pkgver=2.38.0
pkgrel=1
pkgdesc="Quickly rewrite git repository history (filter-branch replacement)"
arch=("any")
url="https://github.com/newren/git-filter-repo"
license=("MIT")
depends=("git" "python")
makedepends=(
	python-build
	python-installer
	python-setuptools-scm
	python-wheel
)
checkdepends=('rsync')
source=(
	"$url/releases/download/v$pkgver/$pkgname-$pkgver.tar.xz"
)
sha256sums=('db954f4cae9e47c6be3bd3161bc80540d44f5379cb9cf9df498f4e019f0a41a9')

prepare() {
	# if it is defined both in setup.cfg and setup.py, installation will explode...
	sed '/scripts/d' -i $pkgname-$pkgver/release/setup.cfg
}

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	cd "$pkgname-$pkgver/release"
	python -m build --wheel --no-isolation
}

check() {
	cd "$pkgname-$pkgver"
	./t/run_tests
}

package() {
	cd "$pkgname-$pkgver/release"
	python -m installer --destdir="$pkgdir" dist/*.whl

	cd ..
	install -Dm644 Documentation/man1/$pkgname.1 -t "$pkgdir/usr/share/man/man1/"
	install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname/" COPYING COPYING.mit
}
